package Fangfalianxi;

import java.util.Random;

//验证码
//需求：定义方法实现随机产生一个5位的验证码
//验证码格式：长度为5，前四位是大写字母或者小写字母，最后一个是数字
public class test3 {
    public static void main(String[] args) {
        char[] chs = new char[52];
        for (int i = 0; i < chs.length; i++) {
            if(i<26){
                chs[i] = (char)(97+i);
            }else{
                chs[i] = (char)(65-26+i);
            }
        }
        Random r = new Random();
       String result = "";
        for (int i = 0;i<4;i++){
            int RandomIndex = r.nextInt(chs.length);
            result = result+chs[RandomIndex];
        }
        int number =  r.nextInt(10);
        result = result+number;
        System.out.println(result);
    }
}
